package com.sinaapp.kjWeb.action;

import java.io.InputStream;
import net.sf.json.JSONObject;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/*
 *auth:徐疆
 *date 2014-1-12 下午7:27:30
 */
public class CheckInAction extends  Action{
	public static Logger logger=LoggerFactory.getLogger(LoginAction.class);
	public CheckInAction(){
		super("签入");
	}
	@Override
	protected void doAction() {
		HttpGet httpget = new HttpGet("http://218.22.63.5:8082/AttendManage/checkin"); 
		httpget.setHeader("Referer", "http://218.22.63.5:8082/home/homeindex");
		InputStream is=null;
		try {
			CloseableHttpResponse checkResponse = this.getHttpClient().execute(httpget);
			is=checkResponse.getEntity().getContent();
			checkStatus(checkResponse);
			JSONObject json=getJsonResult(is);
			if(json!=null){
				String value=String.valueOf(json.get("success"));
				logger.info("登入时："+value);
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("登入出错",e);
			throw new RuntimeException("登入出错");
		}finally{
			IOUtils.closeQuietly(is);
		}
	}
}

